package org.hawk.gwt.ppc.reflect.lang;

import org.hawk.gwt.ppc.reflect.emul.java.lang.reflect.GenericArrayType;
import org.hawk.gwt.ppc.reflect.emul.java.lang.reflect.Type;

/**
 * Implementation of GenericArrayType for internal purposes.
 * Clients should never instantiate this class.
 * 
 * @author alex.bereznevatiy@gmail.com
 */
public class GWTGenericArrayType implements GenericArrayType {
	
	private Object componentType;
	
	public GWTGenericArrayType(Object accessor, Object componentType) {
		GWTParameterizedType.checkAccess(accessor);
		this.componentType = componentType;
	}
	
	public Type getGenericComponentType() {
		if (componentType instanceof Class) {
			return ClassDelegate.forClass((Class<?>)componentType);
		}
		return (Type)componentType;
	}

	@Override
	public String toString() {
		return GWTParameterizedType.toString(componentType) + "[]";
	}
}
